<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript" src="//cdn.bootcss.com/jquery/1.8.3/jquery.min.js"></script>

	</head>

	<body>
		<table class="fk-tb" border="1" cellpadding="3" cellspacing="0">
			<thead>
				<th>姓名</th>
				<th class="f-birth">生日</th>
				<th class="f-operation">操作</th>
			</thead>
			<tbody>
				<tr>
					<td>张三</td>
					<td>2010.1.1</td>
					<td>
						<button class="fk-btn fk-primary f-btn-up" type="button">上移</button>
						<button class="fk-btn fk-primary f-btn-down" type="button">下移</button>
						<button class="fk-btn fk-danger f-btn-remove" type="button">删除</button>
						<button class="fk-btn fk-success f-btn-update" type="button">修改</button>
					</td>
				</tr>
				<tr>
					<td>李四</td>
					<td>2011.1.1</td>
					<td>
						<button class="fk-btn fk-primary f-btn-up" type="button">上移</button>
						<button class="fk-btn fk-primary f-btn-down" type="button">下移</button>
						<button class="fk-btn fk-danger f-btn-remove" type="button">删除</button>
						<button class="fk-btn fk-success f-btn-update" type="button">修改</button>
					</td>
				</tr>
				<tr>
					<td>周五</td>
					<td>2012.1.1</td>
					<td>
						<button class="fk-btn fk-primary f-btn-up" type="button">上移</button>
						<button class="fk-btn fk-primary f-btn-down" type="button">下移</button>
						<button class="fk-btn fk-danger f-btn-remove" type="button">删除</button>
						<button class="fk-btn fk-success f-btn-update" type="button">修改</button>
					</td>
				</tr>
			</tbody>
		</table>
		<button type="button" id="btn">转出</button>
	</body>
	<script>
		$("#btn").on('click', function() {
			exchangeJson();
		})

		/**
		 *将表格的数据转出成json数据 
		 */
		function exchangeJson() {
			var array = [];
			var rows = $(".fk-tb tr").size();
			// var cols = $(".fk-tb td").size();
			//	其实不需要知道有多少列的,我们只需要前面的两列
			//	console.log("rows count:" + rows + " cols count:" + cols);
			for(var i = 1; i < rows; i++) {
				var name = $(".fk-tb tr").eq(i).find("td").eq(0).html();
				var birth = $(".fk-tb tr").eq(i).find("td").eq(1).html();

				//	console.log(name + " " + birth)
				var json = JSON.parse("{\"name\":\"\", \"birthday\":\"\"}");
				json.name = name;
				json.birthday = birth;
				//console.log(json)
				array.push(json);
			}

			//console.log(array);
			alert(JSON.stringify(array))
		}
	</script>

</html>